rm(list =ls())
options(scipen=999)
gc()
packages <-c("tidyverse","estimatr","plm","stargazer",
             "fastDummies","ICCbin","ihs","readstata13","xtable")

new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)

lapply(packages, require, character.only = TRUE)
rm(packages, new.packages)

setwd("PUT YOUR DIRECTORY HERE")

# load data
data <- read.csv("./Datasets/main_confounders.csv")

# scale outcomes
data <- data%>%
  dplyr::mutate(strikes = scale(strikes),
                strikes_1970 = scale(strikes_1970))

# run models
lm_strikes <- lm(strikes ~ strikes_1970, data = data)
summary(lm_strikes)

# out in tex
stargazer(lm_strikes,
          dep.var.labels = c("Protests in the 1980s"),
          style = "qje",
          covariate.labels = c("Protests in the 1970s"),
          star.char = c("*", "**", "***"),
          star.cutoffs = c(0.1, 0.05, 0.01),
          omit = c("Constant", "factor"),
          omit.stat = c("rsq", "f", "ser"), 
          omit.table.layout = "n",
          add.lines = list(c("Fixed effects", "No"),
                           c("Controls", "No")),
          out = "PUT YOUR FILEPATH HERE")
